#ifndef _HEAP_H
#define _HEAP_H

typedef int ElementType;
typedef int (*CompareFunc)(ElementType a, ElementType b);
typedef struct Heap 
{
    int size;
    int curLength;
    int heapIdx;
    CompareFunc cmpFunc;
    ElementType *heapArr;
}Heap;

extern Heap *InitHeap(int size);

extern void PushHeap(Heap *heap, ElementType newElement);

extern ElementType PopHeap(Heap *heap);

extern ElementType GetTop(Heap *heap);

extern int FindElementIdx(Heap *heap, ElementType element);

extern void Clear(Heap *heap);

extern void Swim(Heap *heap, int index);

extern void Sink(Heap *heap, int index);

extern void Swap(ElementType *a, ElementType *b);

#endif